package com.xiaoyushu.note.biz.consumer;

import com.xiaoyushu.note.biz.constants.MQConstants;
import com.xiaoyushu.note.biz.service.NoteService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

@Component
@Slf4j
@RocketMQMessageListener(consumerGroup = "xiaoyushu_group",//Group
        topic = MQConstants.TOPIC_DELETE_NOTE_LOCAL_CACHE,//消费 主题Topic
        messageModel = MessageModel.BROADCASTING //广播模式
)
public class DeleteNoteLocalCacheConsumer implements RocketMQListener<String> {

    @Resource
    private NoteService noteService;
    /**
     * @param s
     */
    @Override
    public void onMessage(String s) {
        Long noteId=Long.valueOf( s);
        log.info("## 删除笔记缓存, noteId: {}", noteId);
        noteService.deleteNoteLocalCache(noteId);

    }
}
